/**
 * Created by Administrator on 2017/1/4.
 */
;(function()
{
    function resize()
    {
        var docEl = document.documentElement;
        var clientWidth = docEl.clientWidth < 750 ? docEl.clientWidth : 750;
        if (!clientWidth) return;
        docEl.style.fontSize = Math.floor(100 * (clientWidth / 750)) + 'px';
    }

    if('onorientationchange' in window) window.addEventListener('onorientationchange', resize, false);
    window.addEventListener('resize', resize, false);
    document.addEventListener('DOMContentLoaded', resize, false);
})();

var gt={
    initHeight:function()
    {
        var h=document.body.clientHeight;
        document.getElementById('main').style.height=h+'px';
    },
    initDeferLoadPageImage: function () {
        var imgDefer = $("img").not('#network-first-load-img');
        imgDefer.each(function () {
            if ($(this).data('src')) {
                $(this).attr('src', $(this).data('src'));
            }
        });
    },
    initOverlay: function () {
        //弹出层
        $('.close-icon').on('tap',function()
        {
            var popup=$(this).data('popup');
            $('#'+popup).hide();
            $('#popup').hide();
        });
        $('#btn-get').on('tap',function(){
            var telephone=$('#input-tel').val();
            if(/^\s+$/gi.test(telephone)||telephone=='')
            {
                $('#input-tel').addClass('error');
            }
            else
            {
                $('#input-tel').removeClass('error');
                var popup=$(this).data('popup');
                $('#popup').show();
                $('#'+popup).show();
                clearInterval(timer);

            }

        });
        var timer;
        $('#btn-get-code').on('tap',function()
        {
            if(!timer)
            {
                var seconds=60;
                var _this=$('#btn-get-code').html('60s');
                _this.addClass('second');
                timer=setInterval(function()
                {
                    seconds--;
                    _this.html(seconds+'s');
                    if(seconds<0)
                    {
                        _this.removeClass('second').html('获取验证码');
                        clearInterval(timer);
                    }
                },1000);
            }

        });
        $('.sec7_mask_rule').on('tap',function()
        {
            $(this).find('.sec7_mask_rule_show').removeClass('rotate-90');
            $(this).siblings('.sec7_mask_rule_list').show();
        });
    }
}
$(function()
{
    gt.initHeight();
    gt.initDeferLoadPageImage();
    gt.initOverlay();
});
